call compile preprocessFile "=BTC=_fnc_server.sqf";
skipTime BTC_p_time;
"BTC_to_server" addPublicVariableEventHandler BTC_m_fnc_only_server;
"BTC_data_to_pass" addPublicVariableEventHandler BTC_s_console_execute;
"BTC_save_sitrep" addPublicVariableEventHandler BTC_s_save_sitrep;
"BTC_canc_sitrep" addPublicVariableEventHandler BTC_s_canc_sitrep;
"BTC_send_sitrep" addPublicVariableEventHandler BTC_s_send_sitrep;
{
	_x setVariable ["BTC_city_status",0,true];
	_x setVariable ["BTC_city_act",0,false];
	//_x setVariable ["BTC_city_units",[],false];
} foreach BTC_main_city;
BTC_main_city_array = BTC_main_city;
[] spawn BTC_city_loop;
if (BTC_p_patrol == 1) then {sleep 30;[] spawn BTC_patrols_control;};
[] spawn BTC_clean_up;
[BTC_quad_1,BTC_quad_2,BTC_quad_3] spawn BTC_service_quads;
//ACRE
if (isClass(configFile >> "cfgPatches" >> "acre_main")) then {_ammo_acre = "ACRE_Radiobox" createVehicle [(getpos BTC_flag select 0) + 1,(getpos BTC_flag select 1) + 1,0];_ammo_acre setvariable ["BTC_Cannot_Lift",1,true];_ammo_acre setvariable ["BTC_Cannot_Drag",1,true];_ammo_acre setvariable ["BTC_Cannot_Place",1,true];};
//Rally point
if (BTC_p_rally == 0) then {deleteVehicle BTC_rally_point;deleteMarker "BTC_rally_point";};
//Planes
if (isClass(configFile >> "cfgPatches" >> "JS_JC_FA18")) then
{
	_plane_1 = createVehicle ["JS_JC_FA18E", getpos BTC_plane_1, [], 0, "NONE"];_plane_1 setVariable ["BTC_dont_delete",[getpos _plane_1,getdir _plane_1],true];_plane_1 setdir 133;
	/*_plane_2 = createVehicle ["JS_JC_FA18E", getpos BTC_plane_2, [], 0, "NONE"];_plane_2 setVariable ["BTC_dont_delete",[getpos _plane_2,getdir _plane_2],true];
	_plane_3 = createVehicle ["JS_JC_FA18F", getpos BTC_plane_3, [], 0, "NONE"];_plane_3 setVariable ["BTC_dont_delete",[getpos _plane_3,getdir _plane_3],true];
	{_x setdir 133;} foreach [_plane_1,_plane_2,_plane_3];*/
};
if (isClass(configFile >> "cfgPatches" >> "BTC_EI_ch49")) then
{
	_helo_1 = createVehicle ["BTC_ch49_EI", getpos BTC_helo_1, [], 0, "NONE"];_helo_1 setVariable ["BTC_dont_delete",[getpos _helo_1,getdir _helo_1],true];_helo_1 setdir 220;
};
//Flag
BTC_flag setFlagTexture "=BTC=_flagpole.paa";
//Save player sys
BTC_jip_client = [];
onPlayerConnected "if (_name != ""__SERVER__"") then {_jip = [_uid] spawn BTC_load_player_sys};";
[] spawn BTC_save_positions_players;
if (isClass(configFile >> "cfgPatches" >> "iniDB")) then
{
	call compile preProcessFile "\iniDB\init.sqf";
};
if (BTC_p_load == 1) then
{
	if (isClass(configFile >> "cfgPatches" >> "iniDB")) then
	{
		if ("BTC_war_storm" call iniDB_exists) then
		{
			_array = [];
			_players = [];
			_db_players = ["BTC_war_storm", "mission", "players_uids"] call iniDB_read;
			_array_players = call compile _db_players;
			{
				private ["_db_player","_array_data"];
				_db_player = ["BTC_war_storm", "mission", _x] call iniDB_read;
				_array_data = call compile _db_player;
				_players = [[_x,_array_data]];
			} foreach _array_players;
			_db_data = ["BTC_war_storm", "mission", "data"] call iniDB_read;
			_db_cities = ["BTC_war_storm", "mission", "cities"] call iniDB_read;
			_db_fobs = ["BTC_war_storm", "mission", "fobs"] call iniDB_read;
			_db_vehicles = ["BTC_war_storm", "mission", "vehicles"] call iniDB_read;
			_db_vehicles_rep = ["BTC_war_storm", "mission", "vehicles_rep"] call iniDB_read;
			_db_ammo = ["BTC_war_storm", "mission", "ammo"] call iniDB_read;
			_db_sit_rep_0 = ["BTC_war_storm", "mission", "sitreps_0"] call iniDB_read;
			_db_sit_rep_1 = ["BTC_war_storm", "mission", "sitreps_1"] call iniDB_read;
			_array_data = call compile _db_data;
			_array_cities = call compile _db_cities;
			_array_fobs = call compile _db_fobs;
			_array_vehicles = call compile _db_vehicles;
			_array_vehicles_rep = call compile _db_vehicles_rep;
			_array_ammo = call compile _db_ammo;
			_array_sit_rep_0 = call compile _db_sit_rep_0;
			_array_sit_rep_1 = call compile _db_sit_rep_1;
			//BTC_load_db = [];
			//BTC_load_db = call compile _db_array;
			_array = [_players,_array_data,_array_cities,_array_fobs,_array_vehicles,_array_vehicles_rep,_array_ammo,[_array_sit_rep_0,_array_sit_rep_1]];
			if (count _array > 0) then {_array call BTC_server_load;};
		};
	}
	else
	{
		if (!isNil {profileNameSpace getVariable "BTC_war_storm"}) then
		{
			_array = profileNameSpace getVariable "BTC_war_storm";
			_array call BTC_server_load;
		};
	};
};
BTC_server_initialized = true;publicVariable "BTC_server_initialized";
